
import { uSelectUserInfo } from '@/api/user';
import { getStorage } from '@/utils/localstoreage';
import { observable, computed, action } from 'mobx'
import { createContext } from 'react';

class Userinfo {
  @observable pageData: {
    devCount: number
    user: UserSetting.UserInfo | null
  } = {
    devCount: 0,
    user: null
  }
  @action.bound
  async updatePageDataSource() {
    let userId = getStorage('userId')
    if (!userId) return
    let res = await uSelectUserInfo({userId})
    if (res && res.result === 'success') {
      this.pageData = res.data
    } else {
      this.pageData = {
        devCount: 0,
        user: null
      }
    }
  }
}
export const userInfoStore = createContext(new Userinfo())
